package main

import (
        "context"
        "fmt"

        openai "github.com/sashabaranov/go-openai"
)

// demo 1 成功调用 chatgpt 的 api
func main() {
        client := openai.NewClient("token")
        resp, err := client.CreateChatCompletion(
                context.Background(),
                openai.ChatCompletionRequest{
                        Model: openai.GPT3Dot5Turbo,
                        Messages: []openai.ChatCompletionMessage{
                                {
                                        Role:    openai.ChatMessageRoleUser,
                                        Content: "你能做什么？",
                                },
                        },
                },
        )

        if err != nil {
                fmt.Printf("ChatCompletion error: %v\n", err)
                return
        }

        fmt.Println(resp.Choices[0].Message.Content)
}